<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>新版本数据导入-皮肤管理</title>
    <link rel="stylesheet" href="Public/Plug/layui/css/layui.css" media="all" />
</head>

<body>
<div class="admin-main">
    <div style="margin: 10px 0px 0px 20px;" class="layui-row">
        <div style="font-size: 18px;font-weight: bold;">皮肤列表</div>
    </div>
    <div style="position: relative;" class="layui-row">
        <div style="margin: 10px 0px 0px 20px;" class="layui-row">
            <div class="layui-col-md9">
                <div>
                    <a href="{U('Skin/index')}" class="layui-btn">返回</a>
                    <button class="layui-btn allRelease">全部发布</button>
                </div>

            </div>
            <div class="layui-col-md3">
                <form class="layui-form" action="">
                    <input type="hidden" name="route" value="Skin/more">
                    <input type="hidden" name="iActId" value="{I('get.iActId')}">
                    <div class="layui-inline">
                        <div class="layui-input-inline">
                            <input type="text" name="search" value="{$search}" placeholder="英雄皮肤名称搜索" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <div class="layui-input-inline">
                            <button class="layui-btn" lay-submit="" lay-filter="search">搜索</button>
                            <button type="reset" class="layui-btn layui-btn-primary reset">重置</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
        <table class="layui-table" style="margin-left: 20px;">
            <thead>
            <tr>

                <th>英雄ID</th>
                <th>皮肤Id</th>
                <th>皮肤名称</th>
                <th>英雄名字</th>
                <th>英雄称号</th>
                <th>炫彩皮肤</th>
                <th style="width: 200px;">皮肤描述</th>
                <th>皮肤发布状态</th>
                <th>皮肤标记类型</th>
                <th>上次编辑</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            {if count($skinsInfo) == 0}
            <tr>
                <td style="text-align: center" colspan="11">没有数据</td>
            </tr>
            {else}
            {foreach $skinsInfo as $k => $val}
            <tr>
                <td>{$val.heroId}</td>
                <td>{$val.skinId}</td>
                <td>{$val.name}</td>
                <td>{$val.heroName}</td>
                <td>{$val.heroTitle}</td>
                <td>{$val.chromas}</td>
                <td>{$val.description}</td>
                <td>{$val.releasestatus}</td>
                <td>{$val.emblemsName}</td>
                <td>{$val.updateTime}</td>
                <td>
                    <button class="layui-btn release" lay-data="{$val.skinId}" lay-hero="{$val.heroId}">发布</button>
                    <button class="layui-btn edit" lay-data="{$val.skinId}" lay-hero="{$val.heroId}">编辑</button>
                    <button {if $val.isBase == 1} style="display: none;" {/if} class="layui-btn delete" lay-data="{$val.skinId}" lay-hero="{$val.heroId}">删除</button>
                </td>
            </tr>
            {/foreach}
            {/if}
            </tbody>
        </table>
        {$page}
    </div>
</div>
    <script type="text/javascript" src="Public/Plug/layui/layui.js"></script>
    <script>
        layui.use(['layer','element','form'], function() {
            var	$ = layui.jquery,
                element = layui.element,
                form = layui.form;
            $('.hero-add').click(function(){
                var url = "{U('Hero/addHero')}";
                $.get(url,function(data){
                    if(data.status == 'error'){
                        layer.msg(data.msg);
                        return;
                    }
                    layer.open({
                        title:'添加英雄',
                        type: 1,
                        skin: 'layui-layer-rim', //加上边框
                        area: ['500px'], //宽高
                        content: data,
                    });
                })
            });
            //编辑皮肤操作
            $('.edit').on("click",function(){

                var skinId = $(this).attr("lay-data");
                var heroId = $(this).attr("lay-hero");

                var str ="<div style='margin: 50px auto 0px;'>";
                str+="<div style='padding: 0px 20px 0px 20px;'>确认编辑当前选中的英雄皮肤数据吗？</div>";
                str+="</div>";
                layer.open({
                    type: 1,
                    title: '皮肤编辑确认',
                    area: ['400px', '200px'] //自定义文本域宽高
                    ,content: str //这里content是一个普通的String
                    ,btn: ['确认', '取消']
                    ,yes: function(index, layero){
                        //按钮【按钮一】的回调
                        var url =  "{U('Skin/index')}";
                        $.post(url,{ skinId: skinId ,heroId: heroId},function(data){
                            if(data.status == 'error'){
                                layer.msg("跳转失败", {
                                    icon: 2,//失败的表情
                                    time: 1000 //2秒关闭（如果不配置，默认是3秒）
                                }, function(){
                                    window.location.href = "{U('Skin/more')}";
                                });
                            }else if(data.status == 'success'){
                                layer.msg("跳转成功", {
                                    icon: 1,//成功的表情
                                    time: 1000 //2秒关闭（如果不配置，默认是3秒）
                                }, function(){
                                    window.location.href = url;
                                });
                            }
                        })
                    }
                    ,btn2: function(index, layero){
                        //按钮【按钮二】的回调

                        //return false 开启该代码可禁止点击该按钮关闭
                    }
                });
            });
            //皮肤发布操作
            $(".release").on("click",function () {

                var skinId = $(this).attr("lay-data");

                var str ="<div style='margin: 30px auto 0px;'>";
                str+="<div style='padding: 0px 20px 0px 20px;'>确认发布当前皮肤吗？</div>";
                str+="</div>";
                layer.open({
                    type: 1,
                    title: '皮肤发布确认',
                    area: ['280px', '160px'] //自定义文本域宽高
                    ,content: str //这里content是一个普通的String
                    ,btn: ['确认', '取消']
                    ,yes: function(index, layero){
                        //按钮【按钮一】的回调
                        var url =  "{U('Skin/skinRelease')}";
                        $.post(url,{ skinId: skinId},function(data){
                            if(data.status == 'error'){
                                layer.msg(data.msg, {
                                    icon: 2,//失败的表情
                                    time: 1000 //2秒关闭（如果不配置，默认是3秒）
                                },function () {
                                    window.location.href =  "{U('Skin/more')}";
                                });
                            }else if(data.status == 'success'){
                                layer.msg(data.msg, {
                                    icon: 1,//成功的表情
                                    time: 1000 //2秒关闭（如果不配置，默认是3秒）
                                }, function(){
                                    window.location.href = "{U('Skin/more')}";
                                });
                            }
                        });
                    }
                    ,btn2: function(index, layero){
                        //按钮【按钮二】的回调
                        //return false 开启该代码可禁止点击该按钮关闭
                    }
                });
            });

            //英雄皮肤全部发布功能
            $(".allRelease").on("click",function () {
                //提示信息
                var str ="<div style='margin: 20px auto 0px;'>";
                str+="<div style='padding: 0px 20px 0px 20px;'>确认发布当前版本全部皮肤吗？</div>";
                str+="</div>";
                layer.open({
                    type: 1,
                    title: '全皮肤发布确认',
                    area: ['280px', '170px'] //自定义文本域宽高
                    ,content: str //这里content是一个普通的String
                    ,btn: ['确认', '取消']
                    ,yes: function(index, layero){
                        //按钮【按钮一】的回调
                        var url =  "{U('Skin/skinRelease')}";
                        $.post(url,{ isAll: 1},function(data){
                            if(data.status == 'error'){
                                layer.msg(data.msg, {
                                    icon: 2,//失败的表情
                                    time: 1000 //1秒关闭（如果不配置，默认是3秒）
                                }, function(){
                                    location.reload();
                                });
                            }else if(data.status == 'success'){
                                layer.msg(data.msg, {
                                    icon: 1,//成功的表情
                                    time: 1000 //1秒关闭（如果不配置，默认是3秒）
                                }, function(){
                                    location.reload();
                                });
                            }
                        })
                    }
                    ,btn2: function(index, layero){
                        //按钮【按钮二】的回调

                        //return false 开启该代码可禁止点击该按钮关闭
                    }
                });
            });

            //英雄皮肤删除操作
            $(".delete").on("click",function () {
                var skinId = $(this).attr("lay-data");
                var heroId = $(this).attr("lay-hero");

                //提示信息
                var str ="<div style='margin: 20px auto 0px;'>";
                str+="<div style='padding: 0px 20px 0px 20px;'>确认发布当前选中的英雄皮肤数据吗？</div>";
                str+="</div>";
                layer.open({
                    type: 1,
                    title: '英雄皮肤删除确认',
                    area: ['400px', '170px'] //自定义文本域宽高
                    ,content: str //这里content是一个普通的String
                    ,btn: ['确认', '取消']
                    ,yes: function(index, layero){
                        //按钮【按钮一】的回调
                        var url =  "{U('Skin/delete')}";
                        $.post(url,{ skinId: skinId,heroId: heroId},function(data){
                            if(data.status == 'error'){
                                layer.msg(data.msg, {
                                    icon: 2,//失败的表情
                                    time: 1000 //1秒关闭（如果不配置，默认是3秒）
                                }, function(){
                                    location.reload();
                                });
                            }else if(data.status == 'success'){
                                layer.msg(data.msg, {
                                    icon: 1,//成功的表情
                                    time: 1000 //1秒关闭（如果不配置，默认是3秒）
                                }, function(){
                                    location.reload();
                                });
                            }
                        })
                    }
                    ,btn2: function(index, layero){
                        //按钮【按钮二】的回调

                        //return false 开启该代码可禁止点击该按钮关闭
                    }
                });
            });

            //监听提交
            form.on('submit(formDemo)', function(data){
                layer.msg(JSON.stringify(data.field));
                return false;
            });
            //重置
            $(".reset").on("click",function () {
                $str = $("input[name='search']").attr('value','');
            });
        });
    </script>
</body>

</html>